In a typical program running on a processor, the program requires the use of memory for a variety of purposes. One purpose is to store the instructions that constitute the program itself. A second purpose is to hold static data, that is, data that is supplied with the program. For example, a racing game's static data may comprise the layout of a race track.
Another purpose is to hold data that is created by the program as it executed. This type of data, which may include data known as dynamically allocated data or the heap, typically holds information which is not known in advance when the program is written. For example, in a game, the player may be provided with the ability to build virtual cars having characteristics selected by the player. Since neither the cars' characteristics nor the number of cars may be known until the program is actually executed by a player, the information cannot be stored in advance. Accordingly, this data will created by the program during its execution.
Yet another purpose of memory is store stacks used by a program. Stacks may be used for many different purposes. For example, because programs typically contain many different routines, different executions of the program may require that the routines be executed in different orders. One stack may keep track of the order in which routines are executed so that the processor can return to a prior routine after the current routine is over. Similarly, the same or a different stack may be used to temporarily store the data associated with one routine while new data is being created and used by another routine.
As is apparent, the efficient execution of a program thus requires the processor to know where all of this information is stored. If the processor needs to jump from one instruction to another, it needs to be able to locate the next instruction. Similarly, it needs to be able to find the statically allocated data, dynamically allocated data, and the stacks.
For this reason, programs typically use addressable memory. Addressable memory allocates memory into individual units having some sort of identifier—typically a number called an “address”—which allows the program to find the instruction or data based on the address. Accordingly, if the processor receives the instruction such as “JUMP 100,” the processor would retrieve and then execute the instruction at address 100.
One of the difficulties associated with a program's use of addresses and access of data is that programs often do not know ahead of time exactly where they will be stored in memory. For example, if a program and its data were stored at addresses 1000 through 2000 the last time it was executed, there is no guarantee that those addresses will be available the next time the program is executed. Thus, the same program may be stored at addresses 3500-4500 the next time it is loaded.
Accordingly, some programs use position independent code (PIC). In PIC, the jump instructions in the program do not recite the actual physical address of the instruction to jump to. Rather, they use a different value, known as a relative address, which is used to calculate or determine the physical address of the instruction to jump to. For example, the instruction “JUMP 100” does not refer to the instruction stored at address 100 in memory. Rather, it may refer to the instruction that is 100 addresses away from the physical address of the beginning of the program.
Systems using PIC convert the relative addresses to actual physical addresses in a number of ways. For example, the physical addresses may be determined at the time the program is loaded into memory, in which case the relative addresses are converted to physical addresses as the program is stored in memory. Alternatively, when a jump instruction is encountered while the program is executing, the processor may calculate the physical address by adding the relative address to a base address that is stored in one of the processor's registers.
One of the difficulties with PIC systems is that they do not adequately address the needs of multi-processing systems. In multi-processor systems, a plurality of sub-processors can operate in parallel (or at least in concert) to achieve desired processing results. Multi-processing systems typically have the ability to migrate programs to be performed from one processor to another.
When a program is migrated from one processor to another in a multi-processing system, it often occurs when the program in the middle of being executed. However, PIC systems are not tailored for such mid-processing moves. Once a PIC program is loaded in memory, its physical address location is known. Accordingly, address pointers to and within data created after the program is loaded and running typically point to physical address locations. Therefore, it is difficult to move all of information associated with a running PIC program to another memory location. Moreover, such programs are susceptible to interrupts in connection with the move.
Accordingly, there is a need for a system and method which permits a more advantageous movement of both programs (including their static data) and the dynamically created data to different processors or address locations.